using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace HandyIRCChat
{
    public partial class JoinChannelForm : Form
    {
        private string channelName = "";

        public JoinChannelForm()
        {
            InitializeComponent();
            CustomInitializeComponent();
        }

        private void CustomInitializeComponent()
        {
            channelNameIn.KeyDown += new KeyEventHandler(OnChannelNameInKeyDown);
        }

        void OnChannelNameInKeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                channelName = channelNameIn.Text;
                this.DialogResult = DialogResult.OK;
            }

            if (e.KeyCode == Keys.Escape)
                this.DialogResult = DialogResult.Cancel;
        }

        private void OnOkButtonClick(object sender, EventArgs e)
        {
            channelName = channelNameIn.Text;
            this.DialogResult = DialogResult.OK;
        }

        private void OnCancelButtonClick(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
        }

        public string ChannelName
        {
            get
            {
                return channelName;
            }
        }
    }
}
